package com.ticket.sass.admin.dto.output.user;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ticket.sass.admin.model.KeyInfoModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author ywb
 * @date 2021-11-15 17:32
 */
@Data
@ApiModel(value = "用户")
public class UserListOutput {
    @ApiModelProperty(value = "主键")
    private Long id;
    
    @ApiModelProperty(value = "昵称")
    private String nickname;
    
    @JsonIgnore
    @ApiModelProperty(value = "头像")
    private String avatar;
    @ApiModelProperty(value = "头像")
    private KeyInfoModel avatarModel;
    
    
    
    @ApiModelProperty(value = "手机号")
    private String cellphone;
    
    @ApiModelProperty(value = "是否会员")
    private Boolean member;
    
    @ApiModelProperty(value = "消费数据")
    private ConsumerData data;
    
    
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createdAt;

    public UserListOutput() {

    }
    
    public KeyInfoModel getAvatarModel() {
        return new KeyInfoModel(avatar);
    }
    
    @Data
    @ApiModel
    public static class ConsumerData{
        @ApiModelProperty(value = "购买次数 (按单计算)", example = "100")
        private Integer purchaseCount;
        
        @ApiModelProperty(value = "退票次数 (按单计算)", example = "10")
        private Integer refundCount;
        
        @ApiModelProperty(value = "卖品次数 (按单计算)", example = "50")
        private Integer commodityCount;
        
        @ApiModelProperty(value = "购买票次数 (按订单中票数计算)", example = "100")
        private Integer purchaseTicketCount;
        
        public ConsumerData() {
            this.purchaseCount = 0;
            this.refundCount = 0;
            this.commodityCount = 0;
            this.purchaseTicketCount = 0;
        }
    }
}
